import 'package:flutter/widgets.dart';
import 'package:tracker/common/extension/build_context_extension.dart';

extension GlobalKeyExtension on GlobalKey {
  /// 获取当前组件的RenderBox
  RenderBox? renderBox() {
    return currentContext?.findRenderObject() as RenderBox?;
  }

  /// 获取当前组件的position
  Offset? position({Offset offset = Offset.zero}) {
    return currentContext?.position(offset: offset);
  }

  /// 获取当前组件的Size
  Size? get size {
    return renderBox()?.size;
  }
}
